
***************************************
* Chapter 3 analyses in text + figures
***************************************

vers 16.1
capture log close
set more off
set scheme plotplain


*mean values for text from the sample of 5 countries

use "wvs7.dta"

mean confios [pweight=S018]
mean confgov [pweight=S018]

* missings
tab confios, missing
tab confgov, missing


* mean in WVS7 dataset of 45 countries in which confidence question was asked, May 2020 release 	 

use "WVS_Cross-national_Wave_7_Stata_v20200502.dta", clear


tab Q88
tab Q88, nol
rename Q88 confWHO
rename Q89 confWTO
rename Q87 confWB
rename Q83 confUN
rename Q84 confIMF
rename Q85 confICC
recode confWTO  -4/-1=. 4=0 3=1 1=3
recode confWHO  -4/-1=. 4=0 3=1 1=3
recode confIMF -4/-1=. 4=0 3=1 1=3
recode confUN -4/-1=. 4=0 3=1 1=3
recode confWB -4/-1=. 4=0 3=1 1=3
recode confICC -4/-1=. 4=0 3=1 1=3

sum confUN confIMF confICC confWB confWHO confWTO
gen confios= (confUN +confIMF +confICC +confWB +confWHO +confWTO)/6

tab Q71
tab Q71, nol
rename Q71 confgov
recode confgov -4/-1=. 4=0 3=1 1=3

mean confios [pweight=S018]
mean confgov [pweight=S018] if confios<.


******************************************
* Figure 3.1
******************************************
use "wvs7.dta", clear

rename country B_COUNTRY

preserve
keep if B_COUNTRY==76|B_COUNTRY==276|B_COUNTRY==608|B_COUNTRY==643|B_COUNTRY==840
collapse confios confUN confIMF confICC confWB confWHO confWTO confgov [pweight=S018], by(B_COUNTRY)
compress 
save "wvs7_meanios_wide_five_c.dta", replace

*merge with overall average
keep if B_COUNTRY==76|B_COUNTRY==276|B_COUNTRY==608|B_COUNTRY==643|B_COUNTRY==840
collapse confios confUN confIMF confICC confWB confWHO confWTO confgov [pweight=S018]
ed
save "wvs7_meanios_wide_all_five_c.dta", replace

cd ""
append using wvs7_meanios_wide_five_c.dta
ed
replace B_COUNTRY=1000 in 1
label define B_COUNTR 76 "Brazil" 276 "Germany" 608 "Philippines" 643 "Russia" 840 "US" 1000 "All", modify
label values B_COUNTRY B_COUNTR
save "wvs7_meanios_wide_all_five_c_plus_total.dta", replace

set scheme plotplain, permanently

gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if B_COUNTRY==76|B_COUNTRY==276|B_COUNTRY==608|B_COUNTRY==643|B_COUNTRY==840

cd ""

keep in 1/8

#delimit ; 
graph bar conf,   
 over(ionum, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal)) legend(col(1) size(medsmall))
 ytitle(Average confidence) title("")
 bar(1, fcolor(gs14) fintensity(100))  
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3_1.gph, replace)
;
#delimit cr

	 
* paired t-tests for Figure 3.1




* mean per IO in WVS7 dataset of 45 countries in which confidence question was asked, May 2020 release 	 

use "WVS_Cross-national_Wave_7_Stata_v20200502.dta", clear

mean confWHO [pweight=S018] if confios<.
mean confUN [pweight=S018] if confios<.
mean confWTO [pweight=S018] if confios<.
mean confICC [pweight=S018] if confios<.
mean confIMF [pweight=S018] if confios<.
mean confWB [pweight=S018] if confios<.


	 
******************************************
*Figure 3.2 - Distribution plot
******************************************

use "wvs7.dta"

svyset
tab country

cd ""

*doing the distribution plot for all IOs does not work, as confios has more than four values

preserve 
contract confUN, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confUN conf
#delimit ;
graph bar percent, 
 over(confUN, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
 ytitle("") title(UN) 
 ylabel(0 "0%" 20 "20%" 40 "40%")
    blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_un.gph, replace) 
;
#delimit cr

preserve
contract confWB, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confWB conf
#delimit ;
graph bar percent, 
 over(confWB, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
 ytitle("") title(World Bank)
 ylabel(0 "0%" 20 "20%" 40 "40%")
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_wb.gph, replace)
;
#delimit cr

preserve 
contract confICC, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confICC conf
#delimit ;
graph bar percent, 
 over(confICC, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
 ytitle("") title(ICC)
 ylabel(0 "0%" 20 "20%" 40 "40%")
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_icc.gph, replace)
 yvaroptions(relabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 
3 "A great deal")) 
;
#delimit cr

preserve 
contract confIMF, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confIMF conf
#delimit ;
graph bar percent, 
 over(confIMF, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
 ytitle("") title(IMF)
 ylabel(0 "0%" 20 "20%" 40 "40%")
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_imf.gph, replace)
 yvaroptions(relabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 
3 "A great deal")) 
;
#delimit cr

preserve 
contract confWHO, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confWHO conf
#delimit ;
graph bar percent, 
 over(confWHO, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
 ytitle("") title(WHO)
 ylabel(0 "0%" 20 "20%" 40 "40%")
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_who.gph, replace)
 yvaroptions(relabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 
3 "A great deal")) 
;
#delimit cr

preserve 
contract confWTO, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confWTO conf
#delimit ;
graph bar percent, 
 over(confWTO, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
 ytitle("") title(WTO)
 ylabel(0 "0%" 20 "20%" 40 "40%")
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_wto.gph, replace)
 yvaroptions(relabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 
3 "A great deal")) 
;
#delimit cr

preserve 
contract confgov, freq(totalno) percent(percent)
label drop _all
label define conf 0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", modify
label values confgov conf
#delimit ;
graph bar percent, 
 over(confgov, label(labcolor(black)  labsize(small))) 
 legend(col(1) size(medsmall))
ytitle("") title(Government)
 ylabel(0 "0%" 20 "20%" 40 "40%")
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.2_gov.gph, replace)
 yvaroptions(relabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 
3 "A great deal")) 
;
#delimit cr

graph combine fig3.2_icc.gph fig3.2_imf.gph fig3.2_un.gph fig3.2_wb.gph  fig3.2_who.gph fig3.2_wto.gph fig3.2_gov.gph, ycommon col(2)







* Figure 3.3
*****************************

cd ""

use "wvs7_meanios_wide_all_five_c_plus_total.dta", clear

preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==4 // IMF

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(IMF)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_IMF.gph, replace)
;
#delimit cr


preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==3 // ICC

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(ICC)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_ICC.gph, replace)
;
#delimit cr

preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==5 // UN

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(UN)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_UN.gph, replace)
;
#delimit cr


preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==6 // WB

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(World Bank)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_WB.gph, replace)
;
#delimit cr


preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==7 // WHO

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(WHO)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_WHO.gph, replace)
;
#delimit cr


preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==8 // WTO

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(WTO)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_WTO.gph, replace)
;
#delimit cr


preserve
gen id=_n
reshape long conf, i(id) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
keep if ionum==2 // gov

#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(Government)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(fig3.3_gov.gph, replace)
;
#delimit cr

graph combine fig3.3_ICC.gph fig3.3_IMF.gph fig3.3_UN.gph fig3.3_WB.gph fig3.3_WHO.gph fig3.3_WTO.gph  fig3.3_gov.gph, ycommon col(2)
 saving(fig3.3.gph, replace)



 
 
 
 
 
 

*Figure 3.4 - Citizen confidence across countries
*********************************************************


*t-tests

use "wvs7.dta"

gen brager=.
gen braphi=.
gen brarus=.
gen braus=.
gen gerphi=.
gen gerrus=.
gen gerus=.
gen phirus=.
gen phius=.
gen ruus=.

replace brager =0 if B_COUNTRY==76
replace brager =1 if B_COUNTRY==276
replace braphi =0 if B_COUNTRY==76
replace braphi =1 if B_COUNTRY==608
replace brarus =0 if B_COUNTRY==76
replace brarus =1 if B_COUNTRY==643
replace braus =0 if B_COUNTRY==76
replace braus =1 if B_COUNTRY==840 

replace gerphi=0 if B_COUNTRY==276
replace gerphi=1 if B_COUNTRY==608
replace gerrus=0 if B_COUNTRY==276
replace gerrus=1 if B_COUNTRY==643
replace gerus=0 if B_COUNTRY==276
replace gerus=1 if B_COUNTRY==840

replace phirus=0 if B_COUNTRY==608
replace phirus=1 if B_COUNTRY==643
replace phius=0 if B_COUNTRY==608
replace phius=1 if B_COUNTRY==840

replace ruus=0 if B_COUNTRY==643
replace ruus=1 if B_COUNTRY==840

ttest confios, by(brager)
ttest confios, by(braphi)
ttest confios, by(brarus)
ttest confios, by(braus)
ttest confios, by(gerphi)
ttest confios, by(gerrus)
ttest confios, by(gerus)
ttest confios, by(phirus)
ttest confios, by(phius)
ttest confios, by(ruus)



*make figure 3.4

use "wvs7.dta"

rename country B_COUNTRY
collapse confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018], by(B_COUNTRY)
reshape long conf, i(B_COUNTRY) j(io) string 
cd ""
save dataforfig3.4_bycountry.dta, replace


use "wvs7.dta"
rename country B_COUNTRY
collapse confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018] 
gen B_COUNTRY=1000
reshape long conf, i(B_COUNTRY) j(io) string 
cd ""
save dataforfig3.4_fivecountryav.dta, replace

append using dataforfig3.4_bycountry.dta
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
label define B_COUNTR 76 "Brazil" 276 "Germany" 608 "Philippines" 643 "Russia" 840 "US" 1000 "5 countries" 5000 "80 countries", modify
label values B_COUNTRY B_COUNTR

cd ""
save fig3.4.dta, replace

sort io
keep in 1/6
#delimit ;
graph bar conf, 
 over(B_COUNTRY, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle(Average confidence) title("")
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(Fig3.4.gph, replace)
;
#delimit cr




******************************************
* North-south analysis, OECD countries=North-south
******************************************

use "WVS_Cross-national_Wave_7_Stata_v20200502.dta", clear

svyset [pweight=S018], strata(B_COUNTRY)

tab A_STUDY //EVS==1
drop if A_STUDY==1

tab Q71
tab Q71, nol
rename Q71 confgov
recode confgov -4/-1=. 4=0 3=1 1=3
tab Q88
tab Q88, nol
rename Q88 confWHO
rename Q89 confWTO
rename Q87 confWB
rename Q83 confUN
rename Q84 confIMF
rename Q85 confICC
recode confWTO  -4/-1=. 4=0 3=1 1=3
recode confWHO  -4/-1=. 4=0 3=1 1=3
recode confIMF -4/-1=. 4=0 3=1 1=3
recode confUN -4/-1=. 4=0 3=1 1=3
recode confWB -4/-1=. 4=0 3=1 1=3
recode confICC -4/-1=. 4=0 3=1 1=3

sum confUN confIMF confICC confWB confWHO confWTO
gen confios= (confUN +confIMF +confICC +confWB +confWHO +confWTO)/6

svy:mean confios if B_COUNTRY_ALPHA=="MEX"
svy:mean confios if B_COUNTRY_ALPHA=="TUR"
svy:mean confios if B_COUNTRY_ALPHA=="AUS"
svy:mean confios if B_COUNTRY_ALPHA=="JPN"

rename B_COUNTRY country
tab country
tab country, nol
gen gn=0
replace gn=1 if country== 36  // AUS
replace gn=1 if country== 152 // CHILE
replace gn=1 if country== 276 // GER
replace gn=1 if country== 300 // GRE
replace gn=1 if country== 392 // JPN
replace gn=1 if country== 410 // KOR
replace gn=1 if country== 484 // MEX
replace gn=1 if country== 792 // TUR
replace gn=1 if country== 840 // USA
tab gn

svy:mean confios if gn==1
svy:mean confios if gn==0

save "gn_gs.dta", replace







* make figure 3.5 - Brazil
*****************************

use "wvs7.dta", clear
rename country B_COUNTRY
collapse confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018], by(B_COUNTRY) 
reshape long conf, i(B_COUNTRY) j(io) string 
ed
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)

cd ""

preserve
keep if B_COUNTRY==76 
#delimit ;
graph bar conf, 
 over(ionum, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(Brazil)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(Fig3.5_Bra.gph, replace)
;
#delimit cr

preserve
keep if B_COUNTRY==276
#delimit ;
graph bar conf, 
 over(ionum, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(Germany)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(Fig3.5_Ger.gph, replace)
;
#delimit cr

preserve
keep if B_COUNTRY==608
#delimit ;
graph bar conf, 
 over(ionum, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(Philippines)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(Fig3.5_Phi.gph, replace)
;
#delimit cr


preserve
keep if B_COUNTRY==643
#delimit ;
graph bar conf, 
 over(ionum, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(Russia)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(Fig3.5_Rus.gph, replace)
;
#delimit cr


preserve
keep if B_COUNTRY==840
#delimit ;
graph bar conf, 
 over(ionum, sort(conf) descending label(labcolor(black) labsize(small))) 
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 ytitle("") title(US)
 bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none)) saving(Fig3.5_Us.gph, replace)
;
#delimit cr

graph combine fig3.5_Bra.gph fig3.5_Ger.gph fig3.5_Phi.gph fig3.5_Rus.gph fig3.5_Us.gph , ycommon col(2) saving(fig3.5.gph, replace)


* paired t-tests for Figure 3.5
1) "That said, the 1.73 average citizen rating of the ICC in the Philippines is still higher than all but one of all other IO scores for the other four countries, exceeded only by 1.80 for the WHO in Germany."


* Figure 3.6 social class
*****************************


use "wvs7.dta", clear

rename Q287 class
tab class
tab class, nol
recode class 1=5 2=4 4=2 5=1

preserve
collapse confios [pweight=S018], by(class) 
label drop _all
label define class 1 "Lower class" 2 "Working class" 3 "Lower middle class" ///
4 "Upper middle class" 5 "Upper class", modify 
label values class class
drop in 6

#delimit ;
graph bar confios, 
over(class)
 ytitle(Average confidence) title("")
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
  bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none))
 saving(fig3.6.gph, replace)
;
#delimit cr

*Figure 3.7

collapse confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018], by(class) 
drop in 6
reshape long conf, i(class) j(io) string 
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)

cd ""
label drop _all
label define class 1 "Lower class" 2 "Working class" 3 "Lower middle class" ///
4 "Upper middle class" 5 "Upper class", modify 
label values class class
#delimit ;
graph bar conf, 
over(io, sort(conf) descending ) by(class) 
 ytitle("") title("")
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 saving(fig3.7.gph, replace)
  bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr









* figure 3.8 age
*****************************


use "wvs7.dta", clear

tab Q262
gen ageg = .
replace ageg = 3 if Q262 >49
replace ageg = 2 if Q262 <50
replace ageg = 1 if Q262 <30
tab ageg
tab ageg, nol
label define agenew 1 "15-29" 2 "30-49" 3 ">50", modify
label values ageg agenew

gen aged=.
replace aged=0 if ageg==1
replace aged=1 if ageg==2
gen aged1=.
replace aged1=0 if ageg==2
replace aged1=1 if ageg==3
gen aged2=.
replace aged2=0 if ageg==1
replace aged2=1 if ageg==3

ttest confios, by(aged)
ttest confios, by(aged1)
ttest confios, by(aged2)

cd ""

preserve
collapse confios [pweight=S018], by(ageg)  
#delimit ;
graph bar confios, 
over(ageg, sort(conf) descending)
 ytitle(Average confidence) title("")
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
  bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none))
 saving(fig3.8.gph, replace)
;
#delimit cr



* t-test significant differences age groups





*Figure 3.9

collapse confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018], by(ageg)
reshape long conf, i(ageg) j(io) string 
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)

cd ""

#delimit ;
graph bar conf, 
over(io, sort(conf) descending) by(ageg)
 ytitle(Average confidence) title("")
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 saving(fig3.9.gph, replace)
  bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr


* t-test significant differences within age groups



* figure 3.10 gender
*****************************


use "wvs7.dta", clear

rename Q260 gender
tab gender
tab gender, nol

keep if B_COUNTRY==76|B_COUNTRY==276|B_COUNTRY==608|B_COUNTRY==643|B_COUNTRY==840

ttest confios, by(gender) 

cd ""

preserve
collapse confios [pweight=S018], by(gender)  
#delimit ;
graph bar confios, 
over(gender, sort(conf) descending)
 ytitle(Average confidence) title("")
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
  bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none))
 saving(fig3.10.gph, replace)
;
#delimit cr


* t-test differences




*figure 3.11

collapse confgov confios confUN confIMF confICC confWB confWHO confWTO [pweight=S018], by(gender) 
reshape long conf, i(gender) j(io) string 
replace io="All IOs" if io=="ios"
replace io="Gov." if io=="gov"
encode io, gen(ionum)
recode gender 2=0
label define sex 0 "Female" 1 "Male"
label values gender sex
cd ""

#delimit ;
graph bar conf, 
over(io, sort(conf) descending) by(gender)
 ytitle(Average confidence) title("")
 ylabel(0 "None at all" 1 "Not very much" 2 "Quite a lot" 3 "A great deal", 
 labsize(small) labcolor(black) angle(horizontal) ///
 glcolor(gs14) gmax) bar(3, color(g2)) legend(col(1) size(medsmall))
 saving(fig3.11.gph, replace)
  bar(1, fcolor(gs14) fintensity(100)) 
 bar(2, fcolor(gs8) fintensity(100)) 
 bar(3, fcolor(gs2) fintensity(100)) 
 blabel(bar, format(%9.2f) size(small) lcolor(none))
;
#delimit cr







